package org.clickframes.plugins.selenium;

import org.clickframes.model.Action;
import org.clickframes.model.Form;
import org.clickframes.model.Page;
import org.clickframes.model.SingleUserInput;
import org.clickframes.model.Validation;
import org.clickframes.plugins.ClickframesPlugin;
import org.clickframes.techspec.Context;

public class Plugin extends ClickframesPlugin {
	@Override
	public void formActionContext(Context actionScope, Page page, Form form, Action action) {
		action.setHtmlId(form.getId() + ":" + action.getId());
	}

	@Override
	public void pageActionContext(Context actionScope, Page page, Action action) {
		// viewIssue:resolveIssue
		action.setHtmlId(page.getName() + ":" + action.getId());
	}

	@Override
	public void inputContext(Context inputScope, Form form, SingleUserInput input) {
		// createAccountCreateAccountForm:createAccountFormUsername
		input.setHtmlId(form.getId() + ":" + input.getId());
	}

	@Override
	public void inputValidationContext(Context inputValidationScope, Form form, SingleUserInput input,
			Validation validation) {
		// createAccountForm:password_message
		//set default if it doesn't already exist
		if (validation.getMessageHtmlId() == null) {
			validation.setMessageHtmlId(form.getId() + ":" + input.getId() + "_message");
		}
	}
}